<script type="text/javascript" src="__STATIC__/admin/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/ueditor/ueditor.all.min.js"></script>

<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="__SELF__" data-auto="true" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" value='{$vo.title|default=""}' required="required" title="请输入名称" placeholder="请输入名称" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class='layui-input-block'>
            <img data-tips-image style="height:auto;max-height:32px;min-width:32px" src="{$vo.thumb|default='static/admin/theme/default/img/image.png'}"/>
            <input type="hidden" name="thumb" onchange="$(this).prev('img').attr('src', this.value)" value="{$vo.thumb|default=''}" class="layui-input">
            <a class="btn btn-link" data-file="one" data-type="png,jpg,jpeg" data-field="thumb">上传图片</a>
            <!-- <p>建议上传图片的尺寸为： (px)。</p> -->
        </div>
    </div>

    {if !empty($patientList)}
    <div class="layui-form-item">
        <label class="layui-form-label">患者</label>
        <div class="layui-input-block" style="z-index: 9999;">
            <select name='pid' required="required" title="请选择患者" class='layui-select full-width'>
                <option value="">请选择患者</option>
                {foreach $patientList as $menu}
                {eq name='menu.id' value='$vo.pid|default=0'}
                <option selected  value='{$menu.id}'>{$menu.username}</option>
                {else/}
                <option  value='{$menu.id}'>{$menu.username}</option>
                {/eq}
                {/foreach}
            </select>
        </div>
    </div>
    {/if}

    {if !empty($characteristicList)}
    <div class="layui-form-item">
        <label class="layui-form-label">诊疗技术</label>
        <div class="layui-input-block" style="z-index: 9998;">
            <select name='cid' required="required" title="请选择诊疗技术" class='layui-select full-width'>
                <option value="">请选择诊疗技术</option>
                {foreach $characteristicList as $menu}
                {eq name='menu.id' value='$vo.cid|default=0'}
                <option selected  value='{$menu.id}'>{$menu.title}</option>
                {else/}
                <option  value='{$menu.id}'>{$menu.title}</option>
                {/eq}
                {/foreach}
            </select>
        </div>
    </div>
    {/if}

    <div class="layui-form-item">
        <label class="layui-form-label">地区</label>
        <div class="layui-input-block" id="aid" style="z-index: 9997;">
        </div>
        <script>
            var aid = xmSelect.render({
                el: '#aid', 
                name: 'aid',
                layVerify: 'required',
                layVerType: 'msg',
                showCount: 10,
                height: '500px',
                autoRow: true,
                toolbar: {
                    show: true,
                },
                tree: {
                    //是否显示树状结构
                    show: true,
                    //是否展示三角图标
                    showFolderIcon: true,
                    //是否显示虚线
                    showLine: false,
                    //间距
                    indent: 20,
                    //默认展开节点的数组, 为 true 时, 展开所有节点
                    expandedKeys: [], 
                    //是否严格遵守父子模式
                    strict: false,
                    //是否开启极简模式
                    simple: false,
                    //点击节点是否展开
                    clickExpand: true,
                    //点击节点是否选中
                    clickCheck: true,
                },
                filterable: true,
                tips:'请选择地区',
                searchTips: '请选择地区',
                empty:'请选择地区',
                emptyTips: '请选择地区',
                data: {:json_encode($newareas)}
            })
        </script>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">病情描述</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入病情描述" title="请输入病情描述" class="layui-textarea" name="illness">{$vo.illness|default=""}</textarea>
        </div>
    </div>
    
    <!-- <div class="layui-form-item">
        <label class="layui-form-label">病情描述</label>
        <div class="layui-input-block" style="z-index:998;">
            <script id="illness" name="illness" type="text/plain">
                
            </script>
        </div>
    </div> -->
    
    <div class="layui-form-item">
        <label class="layui-form-label">病史信息</label>
        <div class="layui-input-block">
            <script id="history" name="history" type="text/plain">
                
            </script>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">诊断信息</label>
        <div class="layui-input-block">
            <script id="diagnosis" name="diagnosis" type="text/plain">
                
            </script>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">诊疗过程</label>
        <div class="layui-input-block">
            <script id="process" name="process" type="text/plain">
                
            </script>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">诊疗结果</label>
        <div class="layui-input-block">
            <script id="result" name="result" type="text/plain">
                
            </script>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">访问权限</label>
        <div class="layui-input-block">
            {volist name="rlist" id="item" key="i"}
            <input type="checkbox" {if condition="$vo['readgroup'] && in_array($item['id'],$vo['readgroup'])"}checked{/if} name="readgroup[{$i}]" value="{$item.id}" title="{$item.title}">
            {/volist}
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        <input type="hidden" id="v-illness" value='{$vo.illness|default=""}'>
        <input type="hidden" id="v-history" value='{$vo.history|default=""}'>
        <input type="hidden" id="v-diagnosis" value='{$vo.diagnosis|default=""}'>
        <input type="hidden" id="v-process" value='{$vo.process|default=""}'>
        <input type="hidden" id="v-result" value='{$vo.result|default=""}'>
        {if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

</form>

<script>window.form.render();</script>

<script type="text/javascript">

    //病情描述
    var ue1 = UE.getEditor('illness');
    ue1.ready(function() {
        ue1.setHeight(200);
        var cont = $("#v-illness").val();
        // alert(cont);return false;
        ue1.setContent(cont);
    });

    //病史信息
    var ue2 = UE.getEditor('history');
    ue2.ready(function() {
        ue2.setHeight(200);
        var cont = $("#v-history").val();
        ue2.setContent(cont);
    });

    //诊断信息
    var ue3 = UE.getEditor('diagnosis');
    ue3.ready(function() {
        ue3.setHeight(200);
        var cont = $("#v-diagnosis").val();
        ue3.setContent(cont);
    });

    //诊疗过程
    var ue4 = UE.getEditor('process');
    ue4.ready(function() {
        ue4.setHeight(200);
        var cont = $("#v-process").val();
        ue4.setContent(cont);
    });

    //诊疗结果
    var ue5 = UE.getEditor('result');
    ue5.ready(function() {
        ue5.setHeight(200);
        var cont = $("#v-result").val();
        ue5.setContent(cont);
    });
</script>
